package com.catsic.core.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.catsic.base.tree.TreeImpl;

/**
 * ClassName: Organ
 * Description: 机构实体
 * date: 2014年2月27日 上午9:28:54
 * author: yanyd
 */
@Entity
@Table(name="S_ORGAN")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Organ extends TreeImpl<Organ> implements Serializable{
	
	/**
	 */
	private static final long serialVersionUID = 7577213209516037806L;
	
	/**
	 * jb:级别
	 */
	@Column(name="JB")
	public Integer jb;
	
	/**
	 * departs:部门
	 */
	@OneToMany(cascade=CascadeType.REMOVE,fetch = FetchType.LAZY,mappedBy="organ") 
    private List<Depart> departs; 
	
	/**
	 * roles:角色
	 */
	@OneToMany(cascade=CascadeType.REMOVE,fetch = FetchType.LAZY,mappedBy = "organ")
    private List<Role> roles; 
	
	/**
	 * users:用户
	 */
	@OneToMany(cascade=CascadeType.REMOVE,fetch = FetchType.LAZY,mappedBy = "organ") 
    private List<User> users;
	
	/**
	 * bindRoles:授权角色，mappedBy = "organs"被维护端
	 */
	@ManyToMany(fetch = FetchType.LAZY,mappedBy = "organs")
	@Cache (usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	private List<Role> bindRoles;
	
	public Integer getJb() {
		return jb;
	}

	public void setJb(Integer jb) {
		this.jb = jb;
	}

	public List<Depart> getDeparts() {
		return departs;
	}

	public void setDeparts(List<Depart> departs) {
		this.departs = departs;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public List<Role> getBindRoles() {
		return bindRoles;
	}

	public void setBindRoles(List<Role> bindRoles) {
		this.bindRoles = bindRoles;
	}
}
